<%--
$Id: book-edit.jsp 24 2011-06-17 13:31:30Z feigme $
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<%@ taglib prefix="iary" uri="/WEB-INF/tld/pagination.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><fmt:message key="user.manager"/></title>
<link href="${ctx }/css/admin/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br/>

<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
	<tr>
		<th class="usertablerow2" colspan="2"><fmt:message key="common.update"/></th>
	</tr>
	<tr>
		<td width="124" valign="top">
			<form:form action="${ctx }/admin/book/upload.do" method="post" enctype="multipart/form-data">
			<input type="hidden" name="id" value="<c:out value="${bookCommand.id }"/>"/>
			<table class="usertableborder" width="100%" align="center" border="0">
				<tr>
					<td class="usertablerow2" colspan="2"><fmt:message key="book.cover"/></td>
				</tr>
				<tr >
					<td class="usertablerow2" colspan="2">
						<fmt:message key="book.path"/><fmt:message key="common.colon"/><c:out value="${book.localPath}"/>
					</td>
				</tr>
				<tr>
					<td class="usertablerow2" colspan="2" width="122" height="179" align="center" valign="middle">
					<c:choose>
						<c:when test="${book.cover==null}">
							<img width="120" height="160" border="0" src="${ctx }/image/cover.jpg" />
						</c:when>
						<c:otherwise>
							<img width="120" height="160" border="0" src="${ctx }/${book.path }${book.cover}" />
						</c:otherwise>
					</c:choose>
					</td>
				</tr>
				<tr>
					<td class="usertablerow2" colspan="2">
						<input type="file" name="cover"/>
					</td>
				</tr>
				<tr >
					<td class="usertablerow2" colspan="2" align="center">
						<input type="button" value="<fmt:message key="book.cover.delete"/>"/>&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="submit" value="<fmt:message key="common.upload"/>"/>
					</td>
				</tr>
			</table>
			</form:form>
		</td>
		<td>
			<form:form action="${ctx }/admin/book/edit.do" method="post" commandName="bookCommand">
			<input type="hidden" name="id" value="<c:out value="${bookCommand.id }"/>"/>
			<input type="hidden" name="orindex" value="<c:out value="${bookCommand.index }"/>"/>
			<input type="hidden" name="orpath" value="<c:out value="${bookCommand.path }"/>"/>
			<table class="usertableborder" style="width:100%;" align="center" border="0">
				<tr>
					<td class="usertablerow2" colspan="4"><fmt:message key="admin.book.create.form"/></td>
				</tr>
				<tr>
					<td class="usertablerow2"><fmt:message key="common.id"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2"><c:out value="${bookCommand.id}"/></td>
					<td class="usertablerow2"><fmt:message key="book.dir"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<input type="text" name="path" size="11" value="<c:out value="${bookCommand.path }"/>"/>
						<span class="error">*</span><br/>
						<form:errors path="path" cssClass="error"/>
					</td>
				</tr>
				<tr>
					<td class="usertablerow2"><fmt:message key="book.name"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<input type="text" name="name" value="<c:out value="${bookCommand.name }"/>"/>
						<span class="error">*</span><br/>
						<form:errors path="name" cssClass="error"/>
					</td>
					<td class="usertablerow2"><fmt:message key="book.index"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<select name="index">
							<option value=""><fmt:message key="common.please.select"/></option>
							<c:forEach items="${bookCommand.indexList}" var="varIndex">
							<c:choose>
								<c:when test="${varIndex == bookCommand.index}">
									<option selected="selected" value="${varIndex}">${varIndex}</option> 
								</c:when>
								<c:otherwise>
									<option value="${varIndex}">${varIndex}</option> 
								</c:otherwise>
							</c:choose>
							</c:forEach>
						</select>
						<span class="error">*</span><br/>
						<form:errors path="index" cssClass="error"/>	
					</td>
				</tr>
				<tr>
					<td class="usertablerow2"><fmt:message key="book.category"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<select name="category">
							<option value=""><fmt:message key="common.please.select"/></option>
							<c:forEach items="${bookCommand.categoryList}" var="varCategory">
							<c:choose>
								<c:when test="${varCategory == bookCommand.category}">
									<option selected="selected" value="${varCategory}"><fmt:message key="book.category.${varCategory}"/></option> 
								</c:when>
								<c:otherwise>
									<option value="${varCategory}"><fmt:message key="book.category.${varCategory}"/></option> 
								</c:otherwise>
							</c:choose>
							</c:forEach>
						</select>
					</td>
					<td class="usertablerow2"><fmt:message key="book.area"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<select name="area">
							<option value=""><fmt:message key="common.please.select"/></option>
							<c:forEach items="${bookCommand.areaList}" var="varArea">
							<c:choose>
								<c:when test="${varArea == bookCommand.area}">
									<option selected="selected" value="${varArea}"><fmt:message key="book.area.${varArea}"/></option> 
								</c:when>
								<c:otherwise>
									<option value="${varArea}"><fmt:message key="book.area.${varArea}"/></option> 
								</c:otherwise>
							</c:choose>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td class="usertablerow2"><fmt:message key="book.author"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<input type="text" name="author" value="<c:out value="${bookCommand.author }"/>"/>
					</td>
					<td class="usertablerow2"><fmt:message key="book.status"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2">
						<c:forEach items="${bookCommand.statusList}" var="varStatus">
						<c:choose>
							<c:when test="${varStatus == bookCommand.status}">
								<input type="radio" checked="checked" name="status" value="${varStatus}"/><fmt:message key="book.status.${varStatus}"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="status" value="${varStatus}"/><fmt:message key="book.status.${varStatus}"/>
							</c:otherwise>
						</c:choose>
						</c:forEach>
					</td>		
				</tr>
				<tr>
					<td class="usertablerow2"><fmt:message key="book.description"/><fmt:message key="common.colon"/></td>
					<td class="usertablerow2" colspan="3"><textarea cols="60" rows="8" name="description"><c:out value="${bookCommand.description }"/></textarea></td>
				</tr>
				<tr>
					<td class="usertablerow2" colspan="4" align="center">
						<input type="submit" value="<fmt:message key="common.submit"/>"/>
						<input type="button" value="<fmt:message key="common.back"/>" onclick="window.location='${ctx}/admin/book/list.do';"/>
					</td>
				</tr>
			</table>
			</form:form>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<table class="usertableborder" style="width:100%;" align="center" border="0">
				<tr>
					<td class="usertablerow2" colspan="5">
						<a href="${ctx }/admin/bookChapter/create.do?bookId=<c:out value="${bookCommand.id}"/>">
							<fmt:message key="common.add"/><fmt:message key="book.chapter"/>
						</a>
					</td>
				</tr>
				<tr>
				<c:forEach items="${book.bookChapters}" var="vchapter" varStatus="index">
					<td class="usertablerow2" align="center">
						<a href="${ctx }/admin/bookChapter/edit.do?bookId=${bookCommand.id}&chapterId=${vchapter.id}"><c:out value="${vchapter.chapterDesc.name}"/>(${vchapter.itemCount })</a>
					</td>
					<c:if test="${index.count%5==0}">
						</tr><tr>
					</c:if>
				</c:forEach>
				</tr>
			</table>
		</td>
	</tr>
</table>

<br/>
</body>
</html>